package com.CST.controller.zx;


import com.CST.annotation.*;
import com.CST.common.api.ResultObject;
import com.CST.common.constant.*;
import com.CST.entity.zx.ZxEtlAccountInfo;
import com.CST.service.zx.IZxEtlAccountInfoService;
import io.swagger.annotations.*;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;

import org.springframework.beans.factory.annotation.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;

import static com.CST.common.method.CommonMethod.getFirstDay;
import static com.CST.common.method.CommonMethod.getLastDay;

/**
 * @author ly
 * @since 2023-03-03
 */
@Api(tags = {"专项凭证操作"})
@RestController
@RequestMapping("/zxEtlAccountInfo")

public class ZxEtlAccountInfoController {

    @Autowired
    private IZxEtlAccountInfoService targetService;


    @PostMapping("/saveOrUpdate")
    @ApiOperation("新建或编辑")
    @ResultObjectAnnotation(value = DmlTypeConstant.INSERT, successMessage = "新建或编辑成功!", errorMessage = "新建或编辑失败!")
    public Object saveOrUpdate(@RequestBody ZxEtlAccountInfo ZxEtlAccountInfo) {
        return targetService.saveOrUpdate(ZxEtlAccountInfo);
    }


    @GetMapping("/getById/{id}")
    @ApiOperation("查看")
    @ResultObjectAnnotation(DmlTypeConstant.SELECT)
    public Object getById(@PathVariable String id) {
        return targetService.getById(id);
    }


    @DeleteMapping("/delete/{ids}")
    @ApiOperation("删除")
    @ResultObjectAnnotation(DmlTypeConstant.DELETE)
    public Object delete(@PathVariable List
            <String> ids) {
        return targetService.removeByIds(ids);
    }

    @GetMapping("CollectVoucherData")
    @ApiOperation("采集凭证数据")
    public ResultObject CollectVoucherData(int year, int month) {

        String result = targetService.CollectVoucherData(year, month);
        if(!"success".equals(result))
        {
            return ResultObject.errorReturn(result);
        }
        return ResultObject.successReturn("采集成功");
    }


}

